package com.ruoyi.erp.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.erp.domain.Fitemss97class;
import com.ruoyi.erp.service.IFitemss97classService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 项目分类Controller
 * 
 * @author ztj
 * @date 2025-11-19
 */
@RestController
@RequestMapping("/erp/fitemss97class")
public class Fitemss97classController extends BaseController
{
    @Autowired
    private IFitemss97classService fitemss97classService;

    /**
     * 查询项目分类列表
     */
    @PreAuthorize("@ss.hasPermi('erp:fitemss97class:list')")
    @GetMapping("/list")
    public TableDataInfo list(Fitemss97class fitemss97class)
    {
        startPage();
        List<Fitemss97class> list = fitemss97classService.selectFitemss97classList(fitemss97class);
        return getDataTable(list);
    }

    /**
     * 导出项目分类列表
     */
    @PreAuthorize("@ss.hasPermi('erp:fitemss97class:export')")
    @Log(title = "项目分类", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Fitemss97class fitemss97class)
    {
        List<Fitemss97class> list = fitemss97classService.selectFitemss97classList(fitemss97class);
        ExcelUtil<Fitemss97class> util = new ExcelUtil<Fitemss97class>(Fitemss97class.class);
        util.exportExcel(response, list, "项目分类数据");
    }

    /**
     * 获取项目分类详细信息
     */
    @PreAuthorize("@ss.hasPermi('erp:fitemss97class:query')")
    @GetMapping(value = "/{iItemCgrade}")
    public AjaxResult getInfo(@PathVariable("iItemCgrade") String iItemCgrade)
    {
        return success(fitemss97classService.selectFitemss97classByIItemCgrade(iItemCgrade));
    }

    /**
     * 新增项目分类
     */
    @PreAuthorize("@ss.hasPermi('erp:fitemss97class:add')")
    @Log(title = "项目分类", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Fitemss97class fitemss97class)
    {
        return toAjax(fitemss97classService.insertFitemss97class(fitemss97class));
    }

    /**
     * 修改项目分类
     */
    @PreAuthorize("@ss.hasPermi('erp:fitemss97class:edit')")
    @Log(title = "项目分类", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Fitemss97class fitemss97class)
    {
        return toAjax(fitemss97classService.updateFitemss97class(fitemss97class));
    }

    /**
     * 删除项目分类
     */
    @PreAuthorize("@ss.hasPermi('erp:fitemss97class:remove')")
    @Log(title = "项目分类", businessType = BusinessType.DELETE)
	@DeleteMapping("/{iItemCgrades}")
    public AjaxResult remove(@PathVariable String[] iItemCgrades)
    {
        return toAjax(fitemss97classService.deleteFitemss97classByIItemCgrades(iItemCgrades));
    }
}
